<?php include_once __DIR__.'/../inc/tie_head.html';?>
<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8 content detail">
      <div class="fly-panel detail-box">
        <h1><?=$info['title']?></h1>
        <div class="fly-detail-info">
          <!-- <span class="layui-badge">审核中</span> -->
          <span class="layui-badge layui-bg-green fly-detail-column"><?=$info['cat_title']?></span>
          <?php if( $info['is_cn']):?>
          <span class="layui-badge" style="background-color: #5FB878;">已结</span>
          <?php else:?>
          <span class="layui-badge" style="background-color: #999;">未结</span>
          <?php endif;?>
          <?php if( $info['is_zd']):?>
          <span class="layui-badge layui-bg-black">置顶</span>
          <?php endif;?>
          <?php if( $info['is_jh']):?>
          <span class="layui-badge layui-bg-red">精帖</span>
          <?php endif;?>
          <?php if( $is_auth_admin):?>
          <div class="fly-admin-box" data-id="<?=$info['id']?>">
            <span class="layui-btn layui-btn-xs jie-admin" type="del">删除</span>
            <?php if($info['is_zd']):?>
            <span class="layui-btn layui-btn-xs jie-admin" type="set" field="is_zd" rank="0" style="background-color:#ccc;">取消置顶</span>
            <?php else:?>
            <span class="layui-btn layui-btn-xs jie-admin" type="set" field="is_zd" rank="1">置顶</span>
            <?php endif;?>
            <?php if( $info['is_jh']):?>
            <span class="layui-btn layui-btn-xs jie-admin" type="set" field="is_jh" rank="0" style="background-color:#ccc;">取消加精</span>
            <?php else:?>
            <span class="layui-btn layui-btn-xs jie-admin" type="set" field="is_jh" rank="1">加精</span>
            <?php endif;?>
          </div>
          <?php endif;?>
          <span class="fly-list-nums">
            <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i> <?=$info['reply_count']?></a>
            <i class="iconfont" title="人气">&#xe60b;</i> <?=$info['views']?>
          </span>
        </div>
        <div class="detail-about">
          <a class="fly-avatar" href="<?=url('user/index',['id'=>$info['user_id']])?>">
            <img src="<?=$info['pic']?$info['pic']:'/static/bbs/images/avatar/default.png';?>" alt="<?=$info['username']?>">
          </a>
          <div class="fly-detail-user">
            <a href="<?=url('user/index',['id'=>$info['user_id']])?>" class="fly-link">
              <cite><?=$info['username']?></cite>
              <?php if($info['is_rz']):?>
              <i class="iconfont icon-renzheng" title="认证信息：<?=$info['username']?>"></i>
              <?php endif;?>
              <?php if( $info['level']):?>
              <i class="layui-badge fly-badge-vip">VIP<?=$info['level']?></i>
              <?php endif;?>
            </a>
            <span><?=com_time_format($info['create_time'],'f')?></span>
          </div>
          <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
            <?php if( $info['score']):?>
            <span style="padding-right: 10px; color: #FF7200">悬赏：<?=$info['score']?>飞吻</span>
            <?php endif;?>
            <?php if($userinfo && ($userinfo['id']==$info['user_id'] || $userinfo['level']>3)):?>
            <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="<?=url('tie/edit',['id'=>$info['id']])?>">编辑此贴</a></span>
            <?php endif;?>
          </div>
        </div>
        <div class="detail-body photos">
            <?=htmlspecialchars_decode($info['content'])?>
        </div>
      </div>

      <div class="fly-panel detail-box" id="flyReply">
        <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
          <legend>回帖</legend>
        </fieldset>

        <ul class="jieda" id="jieda">
        <?php foreach($reply as $v):?>
          <li data-id="<?=$v['id']?>" class="jieda-daan">
            <a name="item-<?=$v['id']?>"></a>
            <div class="detail-about detail-about-reply">
              <a class="fly-avatar" href="<?=url('user/index',['id'=>$v['user_id']])?>">
                <img src="<?=$v['pic']?$v['pic']:'/static/bbs/images/avatar/default.png'?>" alt="<?=$v['username']?>">
              </a>
              <div class="fly-detail-user">
                <a href="<?=url('user/index',['id'=>$v['user_id']])?>" class="fly-link">
                  <cite><?=$v['username']?></cite>
                  <?php if( $v['is_rz']):?>
                  <i class="iconfont icon-renzheng" title="认证信息：<?=$v['username']?>"></i>
                  <?php endif;?>
                  <?php if( $v['level']):?>
                  <i class="layui-badge fly-badge-vip">VIP<?=$v['level']?></i>
                  <?php endif;?>
                </a>
                <!--
                <span>(楼主)</span>
                <span style="color:#5FB878">(管理员)</span>
                <span style="color:#FF9E3F">（社区之光）</span>
                <span style="color:#999">（该号已被封）</span>
                -->
              </div>

              <div class="detail-hits">
                <span><?=com_time_format($v['create_time'],'f')?></span>
              </div>
              <?php if($info['is_cn'] && $v['is_cn']):?>
              <i class="iconfont icon-caina" title="最佳答案"></i>
              <?php endif;?>
            </div>
            <div class="detail-body jieda-body photos">
              <?=$v['content']?>
            </div>
            <div class="jieda-reply">
              <span class="jieda-zan <?php if( in_array($v['id'], $dianzan)):?>zanok<?php endif;?>" type="zan">
                <i class="iconfont icon-zan"></i>
                <em><?=$v['dianzan_count']?></em>
              </span>
              <span type="reply">
                <i class="iconfont icon-svgmoban53"></i>
                回复
              </span>
              <div class="jieda-admin">
                <?php if( $is_auth_admin):?>
                <span type="edit">编辑</span>
                <span type="del">删除</span>
                <?php endif;?>
                <?php if( $is_auth_edit):?>
                <span class="jieda-accept" type="accept">采纳</span>
                <?php endif;?>
              </div>
            </div>
          </li>
        <?php endforeach;?>
          <?php if(count($reply)<1):?>
          <li class="fly-none">消灭零回复</li>
          <?php endif;?>
        </ul>
        <div style="border-top: 1px dotted #e2e2e2; text-align: center;" id="page"></div>
        <div class="layui-form layui-form-pane">
          <form action="<?=url('tie/reply')?>" method="post">
            <div class="layui-form-item layui-form-text">
              <a name="comment"></a>
              <div class="layui-input-block">
                <textarea id="L_content" name="content" required lay-verify="required" placeholder="请输入内容"  class="layui-textarea fly-editor" style="height: 150px;"></textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <input type="hidden" name="tie_id" value="<?=$info['id']?>">
              <button class="layui-btn" lay-filter="myform" lay-submit>提交回复</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <div class="layui-col-md4">
      <?php include_once __DIR__.'/../inc/tie_hot.html';?>
    </div>
  </div>
</div>

<script>
$(document).ready(function(){
    layui.use(['fly','face','jie'],function(){
        var fly = layui.fly;
        fly.faces = layui.face;
        $('.detail-body').each(function(){
          var othis = $(this), html = othis.html();
          othis.html(fly.content(html));
        });
    });
});
</script>
